




/*
*************************************************************************
*西瑞克斯研发管理系统
*版 本: 1.0   
*日 期：03/01/2012    
*作 者： 王浩 QQ：873987060   
*************************************************************************   
*/ 
package com.application.yfsyslog.struts.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.manager.commons.config.ConfigFactory;
import com.manager.commons.page.PageBean;
import com.manager.commons.RandomKey;
import com.manager.commons.CommonUtil;
import com.application.yfsyslog.entity.YfSyslog;
import com.application.yfsyslog.struts.form.YfSyslogForm;
import com.application.yfsyslog.service.YfSyslogService;
import com.application.yfsyslog.commons.Constants;
 /**
 * 
 * Description:YfSyslogAction<br />
 * 
 * Version:V0.1<br />
 * 
 * Author: 王浩 QQ：873987060    <br />
 * 
 * History: <br />
 * 
 * 03/01/2012 
 * 
 */
public class YfSyslogAction extends DispatchAction
{
       
       /**
	 * Service层实例
	 */
	private YfSyslogService yfSyslogService;

	/**
	 * 日志
	 */
	private Logger log = Logger.getLogger(this.getClass());

	/**
	 * 实体对象
	 */
        private YfSyslog yfSyslog;


        /**
	 * 采用partialList方式分页程序
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public ActionForward getYfSyslogPartialList(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		log.debug("searchYfSyslog" + "开始");
		YfSyslogForm yfSyslog = (YfSyslogForm)form;
		// 统计总记录数的sql语句
		int resultSize = 0;
		// 初始化pageBean供分页所用
		PageBean pageBean = null;
		// 取得当前页list数据
		List yfSyslogList = null;
		resultSize = yfSyslogService.getAllCountYfSyslog(yfSyslog);
		pageBean = PageBean.getPageBean("yfSyslogTab", resultSize,request);
		yfSyslogList = yfSyslogService.searchYfSyslog(yfSyslog,pageBean);
		request.setAttribute("yfSyslogList", yfSyslogList);
		request.setAttribute("orgSelect", CommonUtil.getOrgSelect());
		log.debug("searchYfSyslog" + "结束");

		return mapping.findForward(Constants.SUCCESS);
	}

        /**
	 * 到达新增页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toAddYfSyslog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toAddYfSyslogs");
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 增加
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward addYfSyslog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("addYfSyslogs");
		YfSyslog yfSyslog = this.getYfSyslog(form);
        yfSyslog.setId(RandomKey.generateID_Long_19());
		 yfSyslog.setOperateid(CommonUtil.getCurrentUser(request).getId());
		 yfSyslog.setCreateDate(new Date());

		this.yfSyslogService.insertObject(yfSyslog);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 删除
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward deleteYfSyslog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("deleteYfSyslogs");
		YfSyslogForm yfSyslogForm = (YfSyslogForm) form;
		this.yfSyslogService.deleteYfSyslogs(yfSyslogForm);
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 到达更新页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toUpdateYfSyslog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("toUpdateYfSyslogs");

		YfSyslog yfSyslog = this.getYfSyslog(form);
		yfSyslog = this.yfSyslogService.getYfSyslog(yfSyslog);
		request.setAttribute(Constants.YFSYSLOG, yfSyslog);
		return mapping.findForward(Constants.SUCCESS);
	}

        
	/**
	 * 更新
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward updateYfSyslog(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("updateYfSyslogs");
		YfSyslog yfSyslog = this.getYfSyslog(form);
	        yfSyslog.setOperateid(CommonUtil.getCurrentUser(request).getId());
		 yfSyslog.setCreateDate(new Date());
		this.yfSyslogService.updateObject(yfSyslog);

		return mapping.findForward(Constants.SUCCESS);
	}
        
	/**
	 * 查看页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward viewYfSyslog(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		log.debug("viewYfSyslog");

		YfSyslog yfSyslog = this.getYfSyslog(form);
		yfSyslog = this.yfSyslogService.getYfSyslog(yfSyslog);
		request.setAttribute(Constants.YFSYSLOG, yfSyslog);
		return mapping.findForward(Constants.SUCCESS);
	}

	// get--set
	/**
	 * @return the YfSyslogService
	 */
	public YfSyslogService getYfSyslogService() {
		return this.yfSyslogService;
	}

	/**
	 * @param YfSyslogService
	 *  the YfSyslogService to set
	 */
	public void setYfSyslogService(YfSyslogService yfSyslogService) {
		this.yfSyslogService = yfSyslogService;
	}

	/**
	 * 获取YfSyslog实体
	 * @param ActionForm
	 * @throws InvocationTargetException 
	 * @throws IllegalAccessException 
	 * @return the YfSyslog
	 */
	public YfSyslog getYfSyslog(ActionForm form) throws IllegalAccessException, InvocationTargetException {
		YfSyslogForm yfSyslogForm = (YfSyslogForm) form;
		yfSyslog = new YfSyslog();
		BeanUtils.copyProperties(yfSyslog, yfSyslogForm);
		return yfSyslog;
	}
    
        public void setYfSyslog(YfSyslog yfSyslog) {
		this.yfSyslog = yfSyslog;
	}

}
